package DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import MODEL.Maquina;

public class MaquinaDAO {
	
	public void cadastrarMaquina(Maquina maquina) throws SQLException
	{
		Connection conn = null;
		PreparedStatement stmt = null;	
		Conexao com=new Conexao();
		
		try {
			conn=com.getConnection();
		} catch (InstantiationException e) {
			
			e.printStackTrace();
		} catch (Throwable e) {
			
			e.printStackTrace();
		}
		try {
			stmt=conn.prepareStatement("INSERT INTO maquinas(nome_maquina,data_da_compram,disponibilidade,observacoes)value(?,?,?,?)");
			stmt.setString(1,maquina.getMaquina());
			stmt.setString(2,maquina.getData());
			stmt.setString(3,maquina.getDisponibilidade());
			stmt.setString(4,maquina.getObservacoes());
			System.out.println(stmt);
			stmt.execute();
			
			
		} catch (SQLException e) {
		
			e.printStackTrace();
		}
		finally
		{
			if(conn != null)
				conn.close();
			
			if(stmt != null)
				stmt.close();
				
		}
		
	}
	

}
